<?php
declare(strict_types=1);

namespace App\AdminApi\Module\User\Validate;

use App\Common\Enums\SexEnums;
use App\Common\Enums\StatusEnums;
use Zms\Validate\Type;
use Zms\Validate\ValidateAbstract;

class UserValidate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            ['id', Type::REQUIRED, 'error' => '缺少必要参数', 'on' => ['updated']],

            ['nickname', Type::REQUIRED, 'on' => ['created', 'updated']],
            ['nickname', Type::STRING, 'max' => 20, 'on' => ['created', 'updated']],

            ['mobile', Type::MOBILE, 'on' => ['created', 'updated']],

            ['avatar', Type::STRING, 'on' => ['created', 'updated']],

            ['sex', Type::IN, 'enums' => SexEnums::Values(), 'on' => ['created', 'updated']],

            ['level_id', Type::REQUIRED_CHOOSE, 'on' => ['created', 'updated']],
            ['level_id', Type::INT, 'on' => ['created', 'updated']],

            ['tags_ids', Type::LIST, 'type' => 'number', 'on' => ['created', 'updated']],

            ['status', 'in', 'enums' => StatusEnums::Values(), 'on' => ['created', 'updated']]
        ];
    }


    public function labels(): array
    {
        return [
            'nickname' => '会员名称',
            'mobile' => '手机号码',
            'avatar' => '会员头像',
            'sex' => '性别',
            'level_id' => '会员等级',
            'tags_ids' => '会员标签',
            'status' => '会员状态'
        ];
    }
}